#!/usr/bin/env python

from .._app import App
from .._meta import Meta

class Rest(App):

    def __init__(self):
        super(Rest, self).__init__(False)
    
    def run(self):
        self.greeting(Meta())
        
        self.test()
        
        self.warning('\nGood bye ^_^v\n')
                
    def test(self):
        self.progress('Testing RESTful API... ')
        responses = self.restGet('message/pending')
        if responses[0]['status'] == 200:
            self.success('OK ^_^v\n')
        else:
            self.fail('Error >_<\n')
            self.info('Message from server:\n%s' % responses[1]['message'])